- content_for(:title, @service.name)
- content_for(:body_id, 'manage_flow')

= render '/shared/breadcrumbs', breadcrumbs: ["Manage",
                                              link_to("Dashboard", dashboard_index_path),
                                              link_to("Applications", apps_path),
                                              link_to(@app.name, app_path(@app.to_param)),
                                              yield(:title)]

%section.service-details
  .state
    .inspect
      = link_to 'Docker Inspect', '#'
    %span.service-status{ class: @service.status,
        data: { source: app_service_path(@app.id, @service.id, format: :json) } }
      %span.panamax-state= @service.status.to_s.humanize
      .tooltip
        %ul
          %li
            Sub State:
            %span.sub-state= @service.sub_state
          %li
            Active State:
            %span.active-state= @service.active_state
          %li
            Load State:
            %span.load-state= @service.load_state
    %span.metric-details
      %a{ href: metrics_url_for(@service.name), target: '_blank' }
        Details
    %span.metrics{ data: { 'service-name' => @service.name } }
      = render 'shared/metrics'

  .base-image-detail
    .image-details
      %h6 Base Image:
      %span#image-name
        = @service.base_image_name
      %h6 Tag:
      %span
        = @service.image_tag_name
    .documentation
      = link_to('Documentation', '#', { class: 'instructions-dialog', data: {'doc-url'=> documentation_app_path(@app.id)} })  if @app.documentation_to_html.present?
      = link_to 'Find on Docker Hub', @service.docker_search_url, { target: 'blank', data: { 'tracking-method' => 'click', 'tracking-action' => 'Find on Docker Hub', 'tracking-category' => 'Outbound Link', 'tracking-label' => @service.docker_search_url }}
      = link_to "Inspect #{@service.base_image_name} on imagelayers.io", @service.imagelayers_url, title: "View #{@service.base_image_name} on imagelayers.io", class: 'imagelayers-link-with-text', target: '_blank', data: { 'tracking-method' => 'click', 'tracking-action' => 'View on Imagelayers', 'tracking-category' => 'Outbound Link', 'tracking-label' => @service.imagelayers_url }

  = form_for [@app, @service], html: { class: 'service-edit-form' } do |f|
    = render 'shared/errors', errors: f.object.errors
    .service-attributes
      .tab-container
        .tabs.column
          .hide
            %label{ for: 'hide' }
              .icon
              .text Hide Tabs
          .tab
            %label{ for: 'links' }
              .icon
              .text Service Links

          .tab
            %label{ for: 'vars' }
              .icon
              .text
                Environment Variables
          .tab
            %label{ for: 'ports' }
              .icon
              .text
                Ports
          .tab
            %label{ for: 'vols' }
              .icon
              .text
                Volumes
          .tab
            %label{ for: 'run' }
              .icon
              .text
                Docker Run Command
        .cards.column
          .card.links
            = render 'service_links', f: f, services: @app.services, service_id: @service.id, app_id: @app.to_param
          .card.vars
            = render 'environment_variables', f: f
          .card.ports
            .port-detail
              .title
                %h3
                  Ports
                  .service-help-icon
                    .context-help
                      %section.tooltip
                        %aside.arrow
                        %span{ class: 'dismiss' }
                        %p Panamax currently supports port binding (-p) and port expose (--expose).
                        %p To allow Docker to auto assign a host port, leave the 'Host' field blank when adding a port rule.
                        %p Auto-assigned ports will receive a new port number each time the service is restarted. If you wish to control the port number on the host, please specify a host port when adding the rule.
                        %p Click the mapped endpoint to display the GUI, if available, on that port.
                        %p All ports exposed via EXPOSE in the Dockerfile will be noted as exposed by the base image.

              .content
                .port-detail-forms
                  = render 'port_mappings', f: f
                  = render 'exposed_ports', f: f
          .card.vols
            = render 'volumes', f: f, services: @app.services, service_id: @service.id
          .card.run
            .title
              %h3 Docker Run Command
            .content
              .docker-run-command
                = f.text_field :command, placeholder: 'enter run command here (optional)'
        .docker-run.column
          .title
            %h3 Docker Run
          .content
            %p#docker-string

    = f.submit 'Save all changes', class: 'button-positive', data: {disable_with: 'Saving...'}


= render 'shared/journal',
  title: 'CoreOS Journal - Service Activity Log',
  journal_path: journal_app_service_path(@app.id, @service.id, format: :json)

#post-run-html
  = @app.documentation_to_html.html_safe if @app.documentation.present?

#docker-inspect
  %pre
    = JSON.pretty_generate(@service.docker_status)
